import { defineStore } from 'pinia';
import { RouteRecordRaw } from 'vue-router';

interface PermissionState {
  layoutLeftRoutes: RouteRecordRaw[];
}

export const usePermissionStore = defineStore('permission', {
  state: (): PermissionState => ({
    layoutLeftRoutes: [],
  }),
  getters: {
    /**
     * 获取布局左侧的所有路由
     * @returns RouteRecordRaw[]
     */
    layoutLeftRoutesGetter: (state) => state.layoutLeftRoutes,
  },
  actions: {
    async setRoutesList(data: RouteRecordRaw[]) {
      this.layoutLeftRoutes = data;
    },
    /**
     * 清空布局左侧的所有路由
     */
    clearRoutes() {
      this.layoutLeftRoutes = [];
    },
  },
});
